<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>献血证管理系统</title>
  <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
  <link rel="stylesheet" href="/element-theme/blue/index.css">
</head>

<body>
<div class="data-manage-table">
  <template>
    <!--搜索查询-->
    <el-form ref="form" :inline="true" style="padding:20px 20px 0 20px;">

      <el-form-item label="献血证编号">
        <el-input placeholder="请输入献血证编号" v-model="searchSampleToConfirm.certificateNumber"></el-input>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input placeholder="请输入姓名" v-model="searchSampleToConfirm.name"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="clickSearch()">搜索</el-button>
        <el-button type="info" @click="emptySearch">重置</el-button>
        <el-button type="" @click="dialogVisible1 = true">登记</el-button>
        <el-button type="primary" style="margin-right: 40px;" @click="batchDelete()">批量删除</el-button>
<!--        <el-button type="" @click="exportExcel()">导出</el-button>-->
<!--        <el-button type="">打印</el-button>-->
      </el-form-item>
    </el-form>

    <el-dialog title="添加记录" center :visible.sync="dialogVisible1" width="45%" @close="cancel">
      <!-- 内容的主体区域 -->
      <el-form ref="form" :model="addForm" :rules="addFormRules" label-width="100px">
        <el-row>
          <el-col :span="11">
          <el-form-item label="献血证编号" prop="certificateNumber">
            <el-input v-model="addForm.certificateNumber"></el-input>
          </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="addForm.name"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="证件类型" prop="idcardType">
              <el-select v-model="value" placeholder="请选择">
                <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="证件号" prop="idcard">
              <el-input v-model="addForm.idcard" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="献血地点" prop="location">
              <el-input v-model="addForm.location"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="咨询电话" prop="phoneNumber">
              <el-input v-model="addForm.phoneNumber"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="初筛血型" prop="humanBloodType">
              <el-input v-model="addForm.humanBloodType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="献血量" prop="bloodVolume">
              <el-input v-model="addForm.bloodVolume"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="献血类别" prop="bloodType">
              <el-input v-model="addForm.bloodType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item label="既往病史" prop="medicalHistory">
              <el-input v-model="addForm.medicalHistory"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="既往输血史" prop="tansfusionHistory">
          <el-input v-model="addForm.tansfusionHistory"></el-input>
        </el-form-item>
        <el-form-item label="属地" prop="territorial">
          <el-input v-model="addForm.territorial"></el-input>
        </el-form-item>
        <el-form-item label="发证单位" prop="unit">
          <el-input v-model="addForm.unit"></el-input>
        </el-form-item>
        <el-form-item label="献血时间" prop="donationTime">
          <el-date-picker v-model="addForm.donationTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss"
                          placeholder="发生时间" >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="addDonReg()">确 定</el-button>
                </span>
    </el-dialog>

    <el-dialog title="修改记录" center :visible.sync="dialogVisible2" width="45%" @close="cancelRevise">
      <!-- 内容的主体区域 -->
      <el-form ref="form" :model="reviseForm" :rules="reviseFormRules" label-width="100px">
        <!--                <el-form-item label="患者编号" prop="Id">-->
        <!--                    <el-input v-model="reviseForm.serialNumber"></el-input>-->
        <!--                </el-form-item>-->
        <el-form-item label="献血证编号" prop="certificateNumber">
          <el-input v-model="reviseForm.certificateNumber"></el-input>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="reviseForm.name"></el-input>
        </el-form-item>
        <el-form-item label="证件类型" prop="idcardType">
          <el-select v-model="value" placeholder="请选择">
            <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="证件号" prop="idcard">
          <el-input v-model="addForm.idcard"></el-input>
        </el-form-item>
        <el-form-item label="献血地点" prop="location">
          <el-input v-model="reviseForm.location"></el-input>
        </el-form-item>
        <el-form-item label="咨询电话" prop="phoneNumber">
          <el-input v-model="reviseForm.phoneNumber"></el-input>
        </el-form-item>
        <el-form-item label="献血发证单位" prop="unit">
          <el-input v-model="reviseForm.unit"></el-input>
        </el-form-item>
        <el-form-item label="初筛血型" prop="humanBloodType">
          <el-input v-model="reviseForm.humanBloodType"></el-input>
        </el-form-item>
        <el-form-item label="献血量" prop="bloodVolume">
          <el-input v-model="reviseForm.bloodVolume"></el-input>
        </el-form-item>
        <el-form-item label="献血类别" prop="bloodType">
          <el-input v-model="reviseForm.bloodType"></el-input>
        </el-form-item>
        <el-form-item label="既往病史" prop="medicalHistory">
          <el-input v-model="reviseForm.medicalHistory"></el-input>
        </el-form-item>
        <el-form-item label="既往输血史" prop="tansfusionHistory">
          <el-input v-model="reviseForm.tansfusionHistory"></el-input>
        </el-form-item>
        <el-form-item label="属地" prop="territorial">
          <el-input v-model="reviseForm.territorial"></el-input>
        </el-form-item>
        <el-form-item label="献血时间" prop="donationTime">
          <el-date-picker v-model="reviseForm.donationTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss"
                          placeholder="发生时间" >
          </el-date-picker>
        </el-form-item>
      </el-form>
      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
                    <el-button @click="cancelRevise()">取 消</el-button>
                    <el-button type="primary" @click="reviseDonReg()">确 定</el-button>
                </span>
    </el-dialog>

    <el-dialog title="删除记录" center :visible.sync="dialogVisible3" width="45%" @close="cancel">
      <!-- 内容的主体区域 -->

      <!-- 底部区域 -->
      <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="deleteById()">确 定</el-button>
                </span>
    </el-dialog>
    <!-- 献血证登记展示 -->
    <el-table :data="sampleInformation" style="width: 100%" border
              ref="multipleTable"
              type="selection"
              :header-cell-style="{'text-align': 'center','background': '#eef1f6'}" highlight-current-row
              @current-change="" id="out-table">
      <el-table-column type="selection" width="55" align="center"></el-table-column>

      <el-table-column prop="certificateNumber" label="献血证编号" width="100" align="center">
      </el-table-column>

      <el-table-column prop="name" label="姓名" width="100" align="center">
      </el-table-column>

      <el-table-column prop="idcard" label="身份证号" width="100" align="center">
      </el-table-column>

      <el-table-column prop="donationTime" label="献血时间" width="200" align="center">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{scope.row.donationTime}}</span>
        </template>
      </el-table-column>

      <el-table-column prop="location" label="献血地点" width="150" align="center">
      </el-table-column>

      <el-table-column prop="phoneNumber" label="咨询电话" width="150" align="center">
      </el-table-column>

      <el-table-column prop="unit" label="献血证发证单位" width="150" align="center">
      </el-table-column>

      <el-table-column prop="humanBloodType" label="初筛血型" width="100" align="center">
      </el-table-column>

      <el-table-column prop="bloodVolume" label="献血量" width="100" align="center">
      </el-table-column>

      <el-table-column prop="bloodType" label="献血类别" width="100" align="center">
      </el-table-column>

      <el-table-column prop="medicalHistory" label="既往病史" width="150" align="center">
      </el-table-column>

      <el-table-column prop="tansfusionHistory" label="既往输血史" width="150" align="center">
      </el-table-column>

      <el-table-column prop="territorial" label="属地" width="130" align="center">
      </el-table-column>

      <el-table-column fixed="right" label="操作" width="150" align="right">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          </el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination :page-size="pageSize" :total="total" :current-page.sync="current" layout="prev, pager, next, jumper"
                   class="pagination"  @current-change="handleCurrentChange" style="text-align: center; margin-top: 20px;" />
  </template>
</div>

<script src="/plugins/vue-2.5.17/vue.js"></script>
<script src="/plugins/element-2.4.5/index.js"></script>
<script src="/icons/iconfont.js"></script>
<script src="/js/axios.min.js"></script>

<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script language="JavaScript" type="text/javascript">

  //Date原型上添加格式转换方法
  Date.prototype.format = function(fmt) {
    const o = {
      "M+": this.getMonth() + 1,                 //月份
      "d+": this.getDate(),                    //日
      "h+": this.getHours(),                   //小时
      "m+": this.getMinutes(),                 //分
      "s+": this.getSeconds(),                 //秒
      "q+": Math.floor((this.getMonth() + 3) / 3), //季度
      "S": this.getMilliseconds()             //毫秒
    };
    if(/(y+)/.test(fmt)) {
      fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
    }
    for(const k in o) {
      if(new RegExp("("+ k +")").test(fmt)){
        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
      }
    }
    return fmt;
  }
</script>
<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script>
  (function () {
    var vm = window.vm = new Vue({
      el: '.data-manage-table',
      data() {
        //身份证校验
        const checkIdNum = (rule, value, callback) => {
          if (!value) {
            return callback(new Error('身份证不能为空'))
          }
          if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
            callback(new Error('请输入正确的二代身份证号码'))
          } else {
            callback()
          }
        }

        //纯中文校验
        const validateContacts = (rule, value, callback) => {
          if (!value) {
            return callback(new Error('请输入中文'))
          }
          if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(value)) {
            callback(new Error('不可输入特殊字符'))
          } else {
            callback()
          }
        }
        //纯数字校验
        const validateNumber = (rule, value, callback) => {
          let numberReg = /^\d+$|^\d+[.]?\d+$/
          if (value !== '') {
            if (!numberReg.test(value)) {
              callback(new Error('请输入数字'))
            } else {
              callback()
            }
          } else {
            callback(new Error('请输入值'))
          }
        }

        return {
          total: 0,   //总记录数
          current: 1,     //当前页
          pageSize: 10,      //每页记录数
          pages: 0,       //总页数
          signVisible: false,  //样本弹出框
          dialogVisible1: false,  //弹出框显示
          dialogVisible2:false,
          dialogVisible3:false,
          reviseForm: {},
          // searchMode: false,  //false为没有查询条件，true为有查询条件
          currentChanged: false,  //查询模式是否变化
          checkList: ['选中且禁用','复选框 A'],

          //输入查询条件时保存
          searchSampleToConfirm: {
            certificateNumber: '',  //献血证编号
            name: '',  //姓名
          },

          options: [{
            value: '选项1',
            label: '身份证'
          }, {
            value: '选项2',
            label: '港澳台通行证'
          }, {
            value: '选项3',
            label: '护照'
          }, {
            value: '选项4',
            label: '警官证'
          }, {
            value: '选项5',
            label: '签证'
          }],
          value: '',

          //搜索样本信息：点击搜索按钮时带入
          searchSampleInformation: {
            certificateNumber: '',  //献血证编号
            name: '',  //姓名
            dateVal: '',
          },

          //查询到的样本信息
          sampleInformation: [],

          //新增样本信息
          addForm: {
            id:'',
            certificateNumber: '',
            name: '',
            idcardType: '',
            idcard: '',
            donationTime: '',
            location: '',
            unit: '',
            drawPeopleNumber: '',
            humanBloodType: '',
            bloodVolume: '',
            bloodType: '',
            medicalHistory: '',
            tansfusionHistory: '',
            territorial: '',
          },

          reviseForm:{
            id:'',
            certificateNumber: '',
            name: '',
            idcardType: '',
            idcard: '',
            donationTime: '',
            location: '',
            unit: '',
            drawPeopleNumber: '',
            humanBloodType: '',
            bloodVolume: '',
            bloodType: '',
            medicalHistory: '',
            tansfusionHistory: '',
            territorial: '',
          },

          deleteForm:{
            id:'',
            certificateNumber: '',
            name: '',
            idcardType: '',
            idcard: '',
            donationTime: '',
            location: '',
            unit: '',
            drawPeopleNumber: '',
            humanBloodType: '',
            bloodVolume: '',
            bloodType: '',
            medicalHistory: '',
            tansfusionHistory: '',
            territorial: '',
          },

          //修改样本表单验证
          reviseFormRules: {
            // id:[
            //     { required: true, message: '请输入患者编号', trigger: 'blur' },
            // ],
            certificateNumber: [
              { required: true, message: '请输入献血证编号', trigger: 'change' },
            ],
            name: [
              { required: true, message: '请输入姓名', trigger: 'blur' },
            ],
            idcardType: [
              { required: true, message: '请输入证件类型', trigger: 'blur' },
            ],
            idcard: [
              { required: true, message: '请输入证件号', trigger: 'blur' },
              { validator: checkIdNum, trigger: 'blur'},
            ],
            donationTime: [
              { required: true, message: '请输入献血时间', trigger: 'blur' },
            ],
            location: [
              { required: true, message: '请输入献血地点', trigger: 'blur' },
            ],
            phoneNumber: [
              { required: true, message: '请输入咨询电话', trigger: 'blur' },
            ],
            drawPeopleNumber: [
              { required: true, message: '请输入采血者编号', trigger: 'blur' },
            ],
            humanBloodType: [
              { required: true, message: '请输入初筛血型', trigger: 'blur' },
            ],
            bloodVolume: [
              { required: true, message: '请输入献血量', trigger: 'blur' },
            ],
            bloodType: [
              { required: true, message: '请输入献血类别', trigger: 'blur' },
            ],
            medicalHistory: [
              { required: true, message: '请输入既往病史', trigger: 'blur' },
            ],
            tansfusionHistory: [
              { required: true, message: '请输入既往输血史', trigger: 'blur' },
            ],
            territorial: [
              { required: true, message: '请输入属地', trigger: 'blur' },
            ],
          },

          //新增样本表单验证
          addFormRules: {
            certificateNumber: [
              { required: true, message: '请输入献血证编号', trigger: 'change' },
            ],
            name: [
              { required: true, message: '请输入姓名', trigger: 'blur' },
            ],
            idcardType: [
              { required: true, message: '请输入证件类型', trigger: 'blur' },
            ],
            idcard: [
              { required: true, message: '请输入证件号', trigger: 'blur' },
              { validator: checkIdNum, trigger: 'blur'},
            ],
            donationTime: [
              { required: true, message: '请输入献血时间', trigger: 'blur' },
            ],
            location: [
              { required: true, message: '请输入献血地点', trigger: 'blur' },
            ],
            phoneNumber: [
              { required: true, message: '请输入咨询电话', trigger: 'blur' },
            ],
            unit: [
              { required: true, message: '请输入献血证发证单位', trigger: 'blur' },
            ],
            humanBloodType: [
              { required: true, message: '请输入初筛血型', trigger: 'blur' },
            ],
            bloodVolume: [
              { required: true, message: '请输入献血量', trigger: 'blur' },
            ],
            bloodType: [
              { required: true, message: '请输入献血类别', trigger: 'blur' },
            ],
            medicalHistory: [
              { required: true, message: '请输入既往病史', trigger: 'blur' },
            ],
            tansfusionHistory: [
              { required: true, message: '请输入既往输血史', trigger: 'blur' },
            ],
            territorial: [
              { required: true, message: '请输入属地', trigger: 'blur' },
            ],
          }
        }
      },

      computed: {
        //false为没有查询条件，true为有查询条件
        searchMode() {
          if (this.searchSampleInformation.certificateNumber == "" && this.searchSampleInformation.name == "" && this.searchSampleInformation.dateVal == "")
            return false
          else
            return true
        }
      },

      watch: {
        //监听搜索，条件搜索到无条件搜索，current变为1，反之依然
        'searchMode': function (newVal, oldVal) {
          this.currentChanged = true
        },
        //搜素条件改变时，cunrrent也要变为1
        'searchSampleInformation': {
          deep: true,
          handler(newVal, oldVal) {
            this.currentChanged = true
          }
        }
      },

      methods: {
        //分页查询，显示在table中
        fetchPageData(current, limit) {
          axios({
            method: "get",
            url: "/blood_donor/normal/listByPage",
            params: {
              currentPage: this.current,
              pageSize: this.pageSize
            }
          }).then(res => {
            if (res.status == '200') {
              this.sampleInformation = res.data.data;  //更新数据
              console.log(res.data.data)
              this.total = res.data.total;
              this.pages = res.data.pages;
            } else {
              this.total = res.data.total;
              this.pages = res.data.pages;
              this.$notify({
                tile: '警告',
                message: '获取分页服务内部错误',
                type: 'warning'
              })
            }
          }).catch(err => {
            this.$notify.error({
              title: '错误',
              message: '获取分页数据失败',
            })
          })
        },

        handleEdit(index, row){
          this.dialogVisible2 = true
          console.log(row)
          this.reviseForm = row
        },

        handleDelete(index,row){
          this.dialogVisible3 = true
          console.log(row)
          this.deleteForm = row
        },

        //点击页码
        handleCurrentChange: function (val) {
          this.current = val;
          if (!this.searchMode)
            this.fetchPageData(this.current, this.pageSize)
          else
            this.searchSample()
        },

        //点击搜索按钮
        clickSearch(){
          this.current = 1
          this.searchSampleInformation = JSON.parse(JSON.stringify(this.searchSampleToConfirm))
          this.searchSample()
        },

        // 批量删除
        batchDelete() {
          if(JSON.parse(JSON.stringify(this.$refs.multipleTable.selection)).length==0){
            this.$notify({
              title: '温馨提示：',
              message: '您未选中数据，请重新操作！！！',
              type: 'warning'
            });
            return;
          }
          let checkArr = JSON.parse(JSON.stringify(this.$refs.multipleTable.selection));  // 存储了勾选到的数据
          var ids=new Array()
          for(var i=0;i<checkArr.length;i++){
            ids[i]=checkArr[i].id;
          }
          // let data={ids:ids}
          //批量删除
          this.$confirm('确定删除这些数据吗, 是否继续?', '批量删除', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios({
              url: '/blood_donor/normal/batchDelete',
              method: 'put',
              dataType: 'json',
              data:ids
            }).then(res => {
              if (res.data.code == '200') {
                this.$notify({
                  tile: '温馨提示',
                  message: '批量删除成功！！！',
                  type: 'success'
                })
                this.fetchPageData(this.current, this.limit)
              } else {
                this.$notify({
                  tile: '警告',
                  message: '删除出错',
                  type: 'warning'
                })
              }
            }).catch(err => {
              this.$notify.error({
                title: '错误',
                message: '删除失败',
              })
            });
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });
          });
        },

        //根据查询条件查询血液样本
        searchSample() {
          //不良反应编号
          let certificateNumber = this.searchSampleInformation.certificateNumber
          //患者姓名
          let name = this.searchSampleInformation.name
          //操作员

          // if (this.currentChanged) {
          //     this.current = 1
          //     this.currentChanged = false
          // }

          //依据是否有查询条件，进行不一样的查询
          if (!this.searchMode) {
            this.fetchPageData(this.current, this.pageSize)
          } else {
            axios({
              url: '/blood_donor/normal/searchSample',
              method: 'get',
              params: {
                certificateNumber: certificateNumber,
                name: name,
                currentPage: this.current,
                pageSize: this.pageSize
              },
            }).then(res => {
              if (res.status == '200') {
                this.sampleInformation = res.data.data;
                this.total = res.data.total;
                this.pages = res.data.pages;
              } else {
                this.$notify({
                  tile: '警告',
                  message: '搜索出错',
                  type: 'warning'
                })
              }
            }).catch(err => {
              this.$notify.error({
                title: '错误',
                message: '搜索失败',
              })
            })
          }
        },

        //清空搜索条件
        emptySearch() {
          for (const key in this.searchSampleInformation)
            this.searchSampleInformation[key] = ""
          for (const key in this.searchSampleToConfirm)
            this.searchSampleToConfirm[key] = ""
        },

        //添加样本信息
        addDonReg() {
          let newSample = this.addForm
          newSample.donationTime.format("yyyy-MM-dd HH:mm:ss")
          if(this.verifyAddDonReg(newSample)){
            axios({
              url: '/blood_donor/normal/addDonReg',
              method: 'post',
              data: {
                donReg: newSample
              }
            }).then(res => {
              if (res.data.code == '200') {
                console.log('插入成功')
                this.cancel()
                this.$notify({
                  tile: '成功',
                  message: '登记成功',
                  type: 'success'
                })
                this.fetchPageData(this.current, this.limit)
              } else {
                this.$notify({
                  tile: '警告',
                  message: '更新出错',
                  type: 'warning'
                })
              }
            }).catch(err => {
              this.$notify.error({
                title: '错误',
                message: '更新失败',
              })
            })
            this.dialogVisible1 = false
          }
          else {
            alert('样本信息错误')
          }
        },

        //修改样本信息
        reviseDonReg() {
          let newSample = this.reviseForm
          if(this.verifyAddDonReg(newSample)){
            axios({
              url: '/blood_donor/normal/reviseDonReg',
              method: 'put',
              data: {
                donReg: newSample
              }
            }).then(res => {
              if (res.data.code == '200') {
                console.log('插入成功')
                this.cancel()
                this.$notify({
                  tile: '成功',
                  message: '登记成功',
                  type: 'success'
                })
                this.fetchPageData(this.current, this.limit)
              } else {
                this.$notify({
                  tile: '警告',
                  message: '更新出错',
                  type: 'warning'
                })
              }
            }).catch(err => {
              this.$notify.error({
                title: '错误',
                message: '更新失败',
              })
            })
            this.dialogVisible2 = false
          }
          else {
            alert('样本信息错误')
          }
        },

        //新增样本信息检查
        verifyAddDonReg(newSample){
          if (newSample.certificateNumber == '' || newSample.certificateNumber == null)
            return false
          if (newSample.name == '' || newSample.name == null)
            return false
          // if (newSample.bloodNumber.length > 10 || newSample.operatorNumber.length > 20){
          //     console.log('bloodNumber太长')
          //     return false
          // }
          return true
          this.dialogVisible1 = false
        },

        //录入样本：点击确定按钮
        confirmReceive(){
          if (this.currentChanged) {
            this.current = 1
            this.currentChanged = false
          }
          axios({
            url: '/blood_donor/normal/receiveSample',
            method: 'post',
            data: this.receiveForm
          }).then(res => {
            if (res.data.code == '200') {
              if(this.sampleInformation.length == 1)
                this.current = 1
              if(res.data.pages < this.current)
                this.current = res.data.pages
              this.handleCurrentChange(this.current)
              this.signVisible = false
              this.$notify({
                tile: '成功',
                message: '录入成功',
                type: 'success'
              })
            } else {
              this.$notify({
                tile: '警告',
                message: '录入失败',
                type: 'warning'
              })
            }
          }).catch(err => {
            this.$notify.error({
              title: '错误',
              message: '录入失败',
            })
          })
        },

        //删除信息
        deleteById() {
          let sample_select = this.deleteForm;
          if (this.currentChanged) {
            this.current = 1
            this.currentChanged = false
          }
          axios({
            url: '/blood_donor/normal/deleteById',
            method: 'delete',
            data: sample_select
          }).then(res => {
            //需要再次进行查询，同时处理当前页无数据的情况
            if (res.data.code == '200') {
              console.log('current:'+this.current+' length:'+this.sampleInformation.length)
              if(this.sampleInformation.length == 1)
                this.current = 1
              this.handleCurrentChange(this.current)
              this.$notify({
                title: '成功',
                message: '删除成功',
                type: 'success'
              })
            } else {
              this.$notify({
                tile: '警告',
                message: '删除出错',
                type: 'warning'
              })
            }
          }).catch(err => {
            this.$notify.error({
              title: '错误',
              message: '删除失败',
            })
          })
          this.dialogVisible3 = false
        },

        //取消按钮
        cancel(){
          this.addForm.certificateNumber = ''
          this.addForm.name = ''
          this.addForm.idcardType = ''
          this.addForm.idcard = ''
          this.addForm.donationTime = ''
          this.addForm.location = ''
          this.addForm.phoneNumber = ''
          this.addForm.unit = ''
          this.addForm.drawPeopleNumber = ''
          this.addForm.drawPeople = ''
          this.addForm.humanBloodType = ''
          this.addForm.bloodVolume = ''
          this.addForm.bloodType = ''
          this.addForm.medicalHistory = ''
          this.addForm.tansfusionHistory = ''
          this.addForm.territorial = ''
          this.dialogVisible1 = false
          this.dialogVisible3 = false
        },

        //取消按钮
        cancelRevise(){
          this.dialogVisible2 = false
        },

        // //导出excel
        // exportExcel () {
        //   //不良反应编号
        //   let serialNumber = this.searchSampleInformation.serialNumber
        //   //患者姓名
        //   let thePatientName = this.searchSampleInformation.thePatientName
        //   //不良反应发生时间
        //   let reactionTime = this.searchSampleInformation.reactionTime
        //   //不良反应症状
        //   let transfusionReaction = this.searchSampleInformation.transfusionReaction
        //   //反应处理方法
        //   let reactionProcessingMethod = this.searchSampleInformation.reactionProcessingMethod
        //   //原因分析
        //   let causeAnalysis = this.searchSampleInformation.causeAnalysis
        //   //输血信息
        //   let transfusionHistory = this.searchSampleInformation.transfusionHistory
        //   //创建a标签元素
        //   const a = document.createElement('a')
        //   a.href = 'http://localhost:8080/blood_adverse/downloadExcel' + 'serialNumber=' + serialNumber + '&thePatientName=' + thePatientName  + '&reactionTime' + reactionTime + '&transfusionReaction' + transfusionReaction + '&reactionProcessingMethod' + reactionProcessingMethod + '&causeAnalysis' + causeAnalysis + '&transfusionHistory' + transfusionHistory
        //   console.log(a.href)
        //   a.click()
        // }

      },

      mounted() {
        this.fetchPageData(this.current, this.limit)
      }

    },
  );
  })()
</script>

</body>

</html>